PUBLIC = ../../public
SRC = src
BIN = ../../bin
CFLAGS = -Wall -pedantic -ansi -Werror
CC = gcc
LIB_TOOL = ar
LIB_FLAGS = -r -s
COMPILE_FLAG = -c

all: release 

debug: CFLAGS+=-g 
debug: BIN=../../bin/debug
debug: $(BIN)/libTree.a clean
	@echo "**********************************************************"
	@echo "*							*"
	@echo "*		 LIBRARY CREATED			*"
	@echo "*							*"
	@echo "**********************************************************"

release: CFLAGS+=-O3 -DNDEBUG
release: BIN=../../bin/release
release: $(BIN)/libTree.a clean
	@echo "**********************************************************"
	@echo "*							*"
	@echo "*		 LIBRARY CREATED			*"
	@echo "*							*"
	@echo "**********************************************************"

$(BIN)/libTree.a: Tree.o 
	@echo "**********************************************************"
	@echo "*							*"
	@echo "*		CREATING LIBRARY			*"
	@echo "*							*"
	@echo "**********************************************************"
	$(LIB_TOOL) $(LIB_FLAGS) $(BIN)/libTree.a Tree.o 

Testdebug: CFLAGS+=-g -DTREE_UTEST
Testdebug: BIN=bin/debug
Testdebug: $(BIN)/TreeTest clean
	@echo "**********************************************************"
	@echo "*							*"
	@echo "*		SUCCEFULY FINISHED			*"
	@echo "*							*"
	@echo "**********************************************************"


Testrelease: CFLAGS+=-DNDEBUG -DTREE_UTEST
Testrelease: BIN=bin/release
Testrelease: $(BIN)/TreeTest clean
	@echo "**********************************************************"
	@echo "*							*"
	@echo "*		SUCCEFULY FINISHED			*"
	@echo "*							*"
	@echo "**********************************************************"

$(BIN)/TreeTest: Tree.o
	$(CC) $(CFLAGS) Tree.o -o $(BIN)/TreeTest


Tree.o: $(PUBLIC)/Tree.h Tree.c
	$(CC) $(COMPILE_FLAG) $(CFLAGS) -I$(PUBLIC) Tree.c -o Tree.o



clean: 
	rm *.o
